home *** CD-ROM | disk | FTP | other *** search
- /* ---------------------------------------------------------------------------------------------
- Find_icon, code for constructing icon suites for files and folders
-
- by James W. Walker
- preferred e-mail: <mailto:jwwalker@kagi.com>
- alternate e-mail: <mailto:jwwalker@aol.com>, <jim@nisus-soft.com>
- web: <http://users.aol.com/jwwalker/>
-
- File: Copy_each_icon.c
-
- Copyright ©1997 by James W. Walker
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours.
- If you're going to re-distribute the source, please make it clear
- that the code was descended from James W. Walker's code,
- but that you've made changes.
- ---------------------------------------------------------------------------------------------
- */
- #include <Icons.h>
- #include <Resources.h>
- #include "Copy_each_icon.h"
-
- static pascal OSErr Copy_one_icon(
- /* --> */ ResType /* theType */,
- /* <-> */ Handle *theIcon,
- /* --- */ void * /* yourDataPtr */ )
- {
- OSErr err;
-
- if (*theIcon != NULL)
- {
- LoadResource( *theIcon );
- err = HandToHand( theIcon );
- if (err != noErr)
- *theIcon = NULL;
- }
-
- return noErr;
- }
-
- /* ------------------------------------------------------------------
- Copy_each_icon This procedure makes copies of the icon
- handles in a suite, so that they will not
- be resource handles and will not be purgeable. Note that
- if the originals are resources in a file that is in use by other
- programs, then DetachResource would not be appropriate.
- ------------------------------------------------------------------
- */
- OSErr Copy_each_icon(
- /* <-> */ Handle the_suite
- )
- {
- IconActionUPP copy_icon_UPP;
- OSErr err;
-
- copy_icon_UPP = NewIconActionProc( Copy_one_icon );
- err = ForEachIconDo( the_suite, kSelectorAllAvailableData, copy_icon_UPP, NULL );
- DisposeRoutineDescriptor( copy_icon_UPP );
- return err;
- }
-
-